package com.systop.service.impl;

import com.systop.mapper.GoodsTypeMapper;
import com.systop.pojo.Goods_type;
import com.systop.service.GoodsTypeService;
import com.systop.unti.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @Author zhangnan
 * @Data 2020/8/003 下午 4:46
 * @Descriiption
 **/
@Service
@Transactional
public class GoodsTypeServiceImpl implements GoodsTypeService {

    @Autowired
    private GoodsTypeMapper goodsTypeMapper;
    //查询所有商品分类
    @Override
    public ResponseResult selectGoodsTypeAll() {
        List<Goods_type> goods_types = goodsTypeMapper.selectGoodsTypeAll();
        if (goods_types!=null){
            return ResponseResult.ok(goods_types);
        }else {
            return ResponseResult.build(400, "错误");
        }
    }
    //添加商品分类
    @Override
    public ResponseResult insertGoodsType(Goods_type goods_type) {
        Integer integer = goodsTypeMapper.insertGoodsType(goods_type);
        if (integer!=null){
            return ResponseResult.ok(integer);
        }else {
            return ResponseResult.build(400, "错误");
        }
    }
    //修改商品分类之前根据id查询
    @Override
    public ResponseResult selectGoodsTypeByid(Integer goods_type_id) {
        Goods_type goods_type = goodsTypeMapper.selectGoodsTypeByid(goods_type_id);
        if (goods_type!=null){
            return ResponseResult.ok(goods_type);
        }else {
            return ResponseResult.build(400, "错误");
        }
    }
    //根据id更新商品分类
    @Override
    public ResponseResult updateGoodsType(Goods_type goods_type) {
        Integer integer = goodsTypeMapper.updateGoodsType(goods_type);
        if (integer!=null){
            return ResponseResult.ok(integer);
        }else {
            return ResponseResult.build(400, "错误");
        }
    }
    //根据id删除商品分类
    @Override
    public ResponseResult deleteBannerByid(Integer goods_type_id) {
        Integer integer = goodsTypeMapper.deleteBannerByid(goods_type_id);
        if (integer!=null){
            return ResponseResult.ok(integer);
        }else {
            return ResponseResult.build(400, "错误");
        }
    }
}
